home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.text;
-
- import com.sun.java.swing.AbstractAction;
- import com.sun.java.swing.Action;
- import java.awt.event.ActionEvent;
- import java.util.Enumeration;
- import java.util.EventObject;
- import java.util.Hashtable;
-
- public abstract class TextAction extends AbstractAction {
- public TextAction(String name) {
- super(name);
- }
-
- public static final Action[] augmentList(Action[] list1, Action[] list2) {
- Hashtable h = new Hashtable();
-
- for(int i = 0; i < list1.length; ++i) {
- Action a = list1[i];
- String value = (String)a.getValue("Name");
- h.put(value != null ? value : "", a);
- }
-
- for(int i = 0; i < list2.length; ++i) {
- Action a = list2[i];
- String value = (String)a.getValue("Name");
- h.put(value != null ? value : "", a);
- }
-
- Action[] actions = new Action[h.size()];
- int index = 0;
-
- for(Enumeration e = h.elements(); e.hasMoreElements(); actions[index++] = (Action)e.nextElement()) {
- }
-
- return actions;
- }
-
- protected final JTextComponent getFocusedComponent() {
- return JTextComponent.getFocusedComponent();
- }
-
- protected final JTextComponent getTextComponent(ActionEvent e) {
- if (e != null) {
- Object o = ((EventObject)e).getSource();
- if (o instanceof JTextComponent) {
- return (JTextComponent)o;
- }
- }
-
- return this.getFocusedComponent();
- }
- }
-